package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.entity.BaseCategory1;
import com.atguigu.gmall.product.entity.BaseCategory2;
import com.atguigu.gmall.product.entity.BaseCategory3;
import com.atguigu.gmall.product.service.BaseCategory1Service;
import com.atguigu.gmall.product.service.BaseCategory2Service;
import com.atguigu.gmall.product.service.BaseCategory3Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lhh
 * @ClassName BaseCategory1Controller
 * @date 2022 2022/11/29
 */

@Api(tags = "三级分类接口")
@RestController
@RequestMapping("/admin/product")
public class BaseCategory1Controller {

    @Resource
    BaseCategory1Service baseCategory1Service;

    @Resource
    BaseCategory2Service baseCategory2Service;

    @Resource
    BaseCategory3Service baseCategory3Service;

    @ApiOperation(value = "获取一级分类")
    @GetMapping("/getCategory1")
    public Result getCategory1Value(){
        List<BaseCategory1> list = baseCategory1Service.list();
        return Result.ok(list);
    }

    @ApiOperation(value = "获取二级分类")
    @GetMapping("/getCategory2/{category1Id}")
    public Result getCategory2(@PathVariable Long category1Id){
        List<BaseCategory2> list=baseCategory2Service.getgetCategory2ByGetCategory2(category1Id);
        return Result.ok(list);
    }

    @ApiOperation(value ="获取三级列表")
    @GetMapping("/getCategory3/{category2Id}")
    public Result getCategory3(@PathVariable Long category2Id){
        List<BaseCategory3> list=baseCategory3Service.getCategory3ByGetCategory3(category2Id);
        return Result.ok(list);
    }

}
